var bootstrapTableOption = {
    url: 'getEquipmentRealTimeStatus',
    queryParams: function (params) {
        return {
            pageNumber: params.pageNumber,
            pageSize: params.pageSize,
        }
    },
    columns: [
        {title: '序号', formatter: 'increasesWithZero'},
        {field: 'chargingStationName', title: '所属充电站'},
        {field: 'equipmentName', title: '充电桩名称'},
        {field: 'communicateStatus', title: '通讯状态'},    /* 通讯状态：正常/断开 */
        {field: 'workStatus', title: '工作状态'},           /* 工作状态：故障/充电中/空闲/充电结束 */
        {field: 'chargingGun', title: '枪连接状态'},         /*  枪连接状态：已连接/未连接 */
        {field: 'faultCode', title: '故障状态'},             /* 故障状态：正常/故障 */
        {field: 'faultDetails', title: '故障描述'},
        {field: 'currentSOC', title: 'SOC'},
        {field: 'outputVoltage', title: '电压(V)'},
        {field: 'outputElectric', title: '电流(A)'},
        {field: 'outputPower', title: '功率(kW)'},
        {field: 'ammeterNo', title: '当前电表数'},
        {field: 'startChargingDTTM', title: '开始充电时间'},
        {field: 'startChargingAmmeterNo', title: '开始电表数'},
        {field: 'chargedTime', title: '已充时长'},
        {field: 'chargedKWH', title: '已充电量(度)'},
    ],
    responseHandler: function (data) {
        return data;
    }
};

$(document).ready(function () {

    setBootstrapTable('#equipmentStatusTable', bootstrapTableOption);

    /* 修改统计信息内容
    $.ajax({
        url: "equipmentStatusStatistics",
        type: "post",
        dateType: "json",
        success: function (data) {
            for(var i = 0; i < data.length; i++)
                $("#type" + data[i].type).html(data[i].num);
        }
    }); */
});

function setBootstrapTable(id, bootstrapTableOption) {
    $(id).bootstrapTable(
        $.extend(true,
            {
                url: undefined,
                queryParamsType: '',
                queryParams: function (params) { return params;},
                dataField: 'list',
                columns: [[]],
                paginationLoop: false,
                striped: true,
                pagination: true,
                sidePagination: 'server',
                pageSize: 10,
                pageList: [5, 10, 25, 50, 100],
                paginationPreText: "上一页",
                paginationNextText: "下一页",
                buttonsClass: 'select'},
            bootstrapTableOption
        )
    );
}

/* 根据查询条件获取充电站信息 */
function search() {
    $('#equipmentStatusTable').bootstrapTable('selectPage', 1);
}

/* 重置 */
function reset() {
    alert("重置");
}

